﻿@{
    ViewData["Title"] = "CategoryEdit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model Smart_Archives.Entity.SecurityDeviceCategory
<article class="page-container">
    <form class="form form-horizontal" id="form-member-add" onsubmit="return false">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>分组名：</label>
            <input type="hidden" value="@Model.Id" name="id" />
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Name" placeholder="" id="name" name="name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>分组分类：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select class="select" size="1" name="rootId">

                        @foreach (var item in ViewBag.rootCategories)
                        {
                            if (item.Type == Model.Type)
                            {
                                <option value="@item.Id" selected="selected">@item.Name</option>
                            }
                            else
                            {
                                <option value="@item.Id">@item.Name</option>
                            }

                        }

                    </select>
                </span>
            </div>
        </div>
    </form>
    <div class="row cl" style="margin: 20px;">
        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
            <input class="btn btn-primary radius" onclick="submit()" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
        </div>
    </div>

</article>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">

    function submit() { //通过之后回调//进行ajax传值
        var data = $("#form-member-add").serialize();
        $.ajax({
            type: "POST",
            url: "/deviceCategory/CategoryEditProcess",
            dataType: "json",
            data: data,
            success: function (msg) {
                if (msg.succeed) {
                    layer.msg('操作成功!', { icon: 1, time: 1500 }, function () {
                        window.parent.location.reload();
                        parent.layer.close(index);
                    });
                } else {
                    layer.msg('操作失败!', { icon: 1, time: 1500 });
                };
            },
            error: function (msg) {
                layer.msg('操作失败!', { icon: 1, time: 1500 });
            }
        });
    }
</script>
<!--/请在上方写此页面业务相关的脚本-->
